// pages/games/index/index.js
Page({
  data: {
    userPoints: 100,
    games: [
      {
        id: 'slot',
        name: '幸运777',
        icon: '🎰',
        desc: '经典老虎机游戏',
        cost: 2,
        path: '/pages/games/slot/slot'
      },
      {
        id: 'wheel',
        name: '幸运大转盘',
        icon: '🎡',
        desc: '转动转盘赢大奖',
        cost: 5,
        path: '/pages/games/wheel/wheel'
      }
    ]
  },

  onLoad() {
    this.loadUserData();
  },

  onShow() {
    this.loadUserData();
  },

  // 加载用户数据
  loadUserData() {
    const userData = wx.getStorageSync('userData') || {};
    this.setData({
      userPoints: userData.points || 100
    });
  },

  // 导航到老虎机游戏
  navigateToSlot() {
    wx.navigateTo({
      url: '/pages/games/slot/slot'
    });
  },

  // 导航到大转盘游戏
  navigateToWheel() {
    wx.navigateTo({
      url: '/pages/games/wheel/wheel'
    });
  },

  // 导航到扭蛋机游戏
  navigateToTigger() {
    wx.navigateTo({
      url: '/pages/games/tigger/tigger'
    });
  },

  // 分享功能
  onShareAppMessage() {
    return {
      title: '来玩小游戏！赢取丰厚积分奖励',
      path: '/pages/games/index/index',
      imageUrl: '/assets/images/games-share.jpg'
    };
  }
});